package com.xunlai.infra.permission.business.dao.repository;

import com.xunlai.infra.permission.business.dao.entity.Poster;
import com.xunlai.infra.permission.business.dao.entity.vo.PosterTemplateUseVo;
import com.xunlai.infra.permission.business.dao.entity.vo.RouteTemplateCountVo;
import com.xunlai.infra.permission.storage.repository.BaseAllRoundRepository;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
 * @author liang
 * @date 9/7/23 8:18 PM
 */
@Transactional(rollbackFor = Exception.class)
public interface PosterRepository extends BaseAllRoundRepository<Poster,Long> {


    Integer countByCreateUser(Long createUser);

    Optional<Poster> findByPosterNo(String posterNo);

    @Query("select poster_template,count(DISTINCT id) as templateCount from travel_poster where poster_template in (:ids) GROUP BY poster_template ;")
    List<PosterTemplateUseVo> selectTemplateCountByTemplateIn(@Param("ids") Set<Long> templateIds);
}
